package com.woniu.his.sms.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniu.his.result.Result;
import com.woniu.his.sms.client.SmsWorkLoadRecordClient;
import com.woniu.his.sms.client.param.QueryAllDeptWorkLoadParam;
import com.woniu.his.sms.client.result.QueryAllDeptWorkLoadResult;
import com.woniu.his.sms.client.result.QueryWorkLoadByDeptIdResult;
import com.woniu.his.sms.service.WorkloadRecordService;
import com.woniu.his.sms.service.dto.QueryAllDeptWorkLoadDto;
import com.woniu.his.sms.service.dto.QueryWorkLoadByDeptIdDto;
import com.woniu.his.sms.service.param.QueryAllDeptWorkLoadServiceParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
@RequestMapping("/sms")
public class SmsWorkLoadRecordApiImpl implements SmsWorkLoadRecordClient {

    @Resource
    private WorkloadRecordService workloadRecordService;

    @Override
    public Result addWorkLoadRecordForStaff(Long staffId) {

        log.info("统计某个员工工作量传回来的Id：{}",staffId);
        workloadRecordService.addWorkLoadRecordForStaff(staffId);
        return Result.getInstance();
    }

    @Override
    public Result<QueryAllDeptWorkLoadResult> queryAllDeptWorkLoad(QueryAllDeptWorkLoadParam param) {

        log.info("查询所有科室工作量的入参：{}",param);
        QueryAllDeptWorkLoadServiceParam serviceParam= BeanUtil.copyProperties(param,QueryAllDeptWorkLoadServiceParam.class);
        QueryAllDeptWorkLoadDto dto=workloadRecordService.queryAllDeptWorkLoad(serviceParam);
        QueryAllDeptWorkLoadResult result=BeanUtil.copyProperties(dto,QueryAllDeptWorkLoadResult.class);
        return Result.getInstance(QueryAllDeptWorkLoadResult.class).setData(result);
    }

    @Override
    public Result<QueryWorkLoadByDeptIdResult> queryWorkLoadByDeptId(Long deptId) {

        log.info("查询某个科室工作量的入参：{}",deptId);
        QueryWorkLoadByDeptIdDto dto=workloadRecordService.queryWorkLoadByDeptId(deptId);
        QueryWorkLoadByDeptIdResult result=BeanUtil.copyProperties(dto,QueryWorkLoadByDeptIdResult.class);
        return Result.getInstance(QueryWorkLoadByDeptIdResult.class).setData(result);
    }
}
